<?php
// +----------------------------------------------------------------------
// | WoShiMaiJia Projcet 
// +----------------------------------------------------------------------
// | Copyright (c) 2010-2011 http://woshimaijia.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: xinqiyang <xinqiyang@gmail.com>
// +----------------------------------------------------------------------

class AccountLogic extends BaseService
{
	
	public static function webPageSetting($params)
	{
		
		if(isset($params['id']))
		{
			return self::blockAccount($params);
		}
		return false;
	}
	
	
	
	public static function blockAccount($params)
	{
		if(isset($params['id']))
		{
			return self::redisGetHashes($params);
		}
		return false;
	}
	
	public static function actSignUp($params)
	{
		return AccountService::signUp($params);
	}
	
	public static function actSave($params)
	{
		if(is_array($params) && isset($params['id']))
		{
			return self::saveClean('account', $params);
		}
	}
	
	public static function actPassword($params)
	{
		
		$account = self::blockAccount($params);
		if(!empty($account['password']) && $account['password']== $params['password'])
		{
			$params['password'] = $params['newpassword'];
			unset($params['newpassword']);
			//@TODO do logout
			return self::actSave($params);
		}
		return false;
	}
	
	public static function actSaveUserinfo($params)
	{
		if(is_array($params) && isset($params['id']))
		{
			$r = self::save('userinfo', $params);
			if($r){
				$key = 'h:userinfo:'.$params['id'];
				self::redisDeleteKeys(array($key));
				return true;
			}
			return false;
		}
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
}